package com.ruoyi.jeeplus.modules.screen.frontdesk.screen_PV.controller;

import com.ruoyi.jeeplus.modules.screen.frontdesk.screen_PV.domain.Frontdesk_screen_PV;
import com.ruoyi.jeeplus.modules.screen.frontdesk.screen_PV.mapper.FrontdeskScreenPVMapper;
import com.ruoyi.jeeplus.modules.screen.frontdesk.screen_PV.service.impl.Frontdesk_screenServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 刘奥旸
 * @version 1.0
 */
@RestController
public class Frontdesk_screen_PVController {
    @Autowired
    Frontdesk_screenServiceImpl frontdesk_screenService;
    @Autowired
    FrontdeskScreenPVMapper frontdeskScreenPVMapper;
//测试通过了，返回子类
    @GetMapping(value = "/lay/PVexer")
    private List lay(@RequestParam String id,@RequestParam String date){
        List<Frontdesk_screen_PV> layexer = frontdesk_screenService.exer(id, date);

        // 创建一个 List 集合
        List<Integer> numbers = new ArrayList<>();
        // 添加元素
        numbers.add(100);
        numbers.add(200);
        numbers.add(300);
        numbers.add(400);
        numbers.add(500);
        numbers.add(400);
        System.out.println(numbers);
        return layexer;
    }
//测试中计算子类，成功了
    @GetMapping(value = "/lay/PV")
    private List<BigDecimal> user(@RequestParam String id, @RequestParam int date){
        // 正则表达式判断 id 是否是数字
        if (id.matches("^[0-9]+$")) {
            // 如果 id 是数字，执行数字相关的逻辑
            return frontdesk_screenService.laynew(id, date);
        }
        else {//这是省的逻辑，文字查出来
            List<BigDecimal> numbers = new ArrayList<>();
            Integer region_id = frontdeskScreenPVMapper.getIdByName(id);
            String region = region_id + "";
            return frontdesk_screenService.laynew(region, date);
            //numbers.add(new BigDecimal("10.50")); // 添加第一个数字
            //numbers.add(new BigDecimal("20.75")); // 添加第二个数字
           //numbers.add(new BigDecimal("5.25"));  // 添加第三个数字
           // numbers.add(new BigDecimal("10.50")); // 添加第一个数字
            //numbers.add(new BigDecimal("20.75")); // 添加第二个数字
            //numbers.add(new BigDecimal("5.25"));  // 添加第三个数字
            //throw new IllegalArgumentException("ID must be either a number or Chinese characters.");
        //return numbers;
        }
        //List<BigDecimal> frontdeskScreenPvs = frontdesk_screenService.laynew(id,date);
       // System.out.println(frontdeskScreenPvs);
        //return frontdeskScreenPvs;
    }
    @GetMapping(value = "/lay")
    private String userw(@RequestParam int id){
        String todayDate = frontdesk_screenService.getTodayDate(id);
        return todayDate;

    }

}
